<template>

  <div style="height: 100vh;">
    <el-header style="height: 6vh;">ManageSystem
      <el-dropdown style="right: 0;top:1vh; height: 2vh; line-height: 2vh;margin-right:10px; position: absolute">
        <span class="el-dropdown-link" style="color: black">{{ user.name }}<i
            class="el-icon-arrow-down el-icon--right"></i></span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>
            <div @click="quit">退出登录</div>
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </el-header>
    <div>
      <!--      height: 631px;-->
      <el-container style="height: 94vh; border: 1px solid #ededed;overflow: hidden;">
        <el-aside width="230px" style="border: 1px solid #ededed">
          <el-menu :default-openeds="['1','2','3','4']" router>
            <el-submenu index="1" v-show="myInfo.role==='超级管理员'||myInfo.role==='机构管理员'">
              <template slot="title"><i class="el-icon-message"></i>信息管理</template>
              <el-menu-item-group>
                <el-menu-item index="/agency" v-show="theMajorOfMy">机构管理</el-menu-item>
                <el-menu-item index="/user">账号信息管理</el-menu-item>
                <el-menu-item index="/documentVideoManage">文档视频管理</el-menu-item>
                <el-menu-item index="/testQuestion">试题管理</el-menu-item>
                <el-menu-item index="/trainingPlan">培训计划管理</el-menu-item>
                <el-menu-item index="/learningSituation">学员学习情况</el-menu-item>
                <el-menu-item index="/examSituation">学员考试情况</el-menu-item>
              </el-menu-item-group>

            </el-submenu>
            <el-submenu index="2" v-show="myInfo.role==='超级管理员'||myInfo.role==='机构管理员'">
              <template slot="title"><i class="el-icon-message"></i>基础参数管理</template>
              <el-menu-item-group>
                <el-menu-item index="/agencyTypeManage" v-show="theMajorOfMy">机构类型的管理</el-menu-item>
                <el-menu-item index="/trainingCycleManage" v-show="theMajorOfMy">培训周期管理</el-menu-item>
                <el-menu-item index="/trainingTypeManage" v-show="theMajorOfMy">培训类型管理</el-menu-item>
                <el-menu-item index="/documentVideoTypeManage" v-show="theMajorOfMy">文档视频类型管理</el-menu-item>
                <el-menu-item index="/consultManage">前端咨询展示列表管理</el-menu-item>
              </el-menu-item-group>

            </el-submenu>
            <el-submenu index="3"
                        v-show="myInfo.role==='审核人员'||myInfo.role==='发布人员'">
              <template slot="title"><i class="el-icon-message"></i>审核</template>
              <el-menu-item-group>
                <el-menu-item index="/documentVideoReview">视频审核发布
                </el-menu-item>
              </el-menu-item-group>
            </el-submenu>
            <el-submenu index="4" v-show="myInfo.role==='学员'||myInfo.role==='机构管理员'||myInfo.role==='超级管理员'">
              <template slot="title"><i class="el-icon-message"></i>首页</template>
              <el-menu-item-group>
                <el-menu-item index="/agencyHomePage">机构首页</el-menu-item>
                <el-menu-item index="/trainingPlanForStudent">培训计划</el-menu-item>
                <el-menu-item index="/InfoManage">个人信息管理</el-menu-item>
                <el-menu-item index="/consult" v-show="myInfo.role==='学员'">咨询</el-menu-item>
              </el-menu-item-group>
            </el-submenu>
          </el-menu>
        </el-aside>


        <el-container>
          <el-main>
            <router-view></router-view>
          </el-main>
        </el-container>
      </el-container>


    </div>


  </div>


</template>
<script>


import {changeUser, getInfo} from "@/api/user";
import Router from "@/router";
import {getToken, removeToken} from "@/utils/auth";

export default {
  data() {
    return {
      tableData: [],
      searchForm: {
        name: "",
        gender: "",
        entrydate: []
      },
      user: {},
      myInfo: "",
      theMajorOfMy: "",
    }
  },

  methods: {

    getMyInfo() {
      getInfo().then((res) => {
        //console.log(res)
        if (res.data.code === 1) {
          this.myInfo = res.data.data;
          if (res.data.data.role === '超级管理员') {
            this.theMajorOfMy = true;
          }
        }
      }).catch((e) => {
      })
    },
    quit() {
      removeToken();
      Router.push('/login');
    },

  },
  mounted() {
    let token = getToken();
    if (token == null) {
      window.location.href = ("/login");
    }
    this.getMyInfo();
  }
};
</script>


<style>
* {
  margin: 0;
  padding: 0;
}

.el-header {
  background-color: rgb(238, 241, 246);
  color: #333;
  line-height: 60px;
}

.el-aside {
  color: white;
}

</style>
